﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using FS.Business;
using FS.Common.DotNetCode;
using FS.Common.DotNetUI;

namespace FS.Web.BLL.Visa
{
    public partial class Visa_ResultVisaList : PageBase
    {
        private visa_dao _visa = new visa_dao();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.PageControl1.pageHandler += new EventHandler(this.pager_PageChanged);
            if (!base.IsPostBack)
            {
                GetSelect_SupplyInfo();
                GetSelect_TrustInfo();
                GetSelect_City();
                GetSelect_Certtype();
            }
        }

        #region 初始项目数据绑定
        //委托方
        private void GetSelect_TrustInfo()
        {
            DataTable dt = _visa.GetSelect_TrustInfo();
            ControlBindHelper.BindHtmlSelect(dt, this.sel_trust, "name", "trust_id", "请选择");
        }

        //所属国家
        private void GetSelect_City()
        {
            DataTable dt = _visa.GetSelect_CityInfo();
            ControlBindHelper.BindHtmlSelect(dt, this.sel_cityid, "city_name", "city_id", "请选择");
        }

        //签证类型
        private void GetSelect_Certtype()
        {
            DataTable dt = _visa.GetSelect_CertType();
            ControlBindHelper.BindHtmlSelect(dt, this.sel_certtype, "property_value", "property_id", "请选择");
        }

        //供应商
        public void GetSelect_SupplyInfo()
        {
            DataTable dt = _visa.GetSelect_SupplyInfo();
            ControlBindHelper.BindHtmlSelect(dt, this.sel_supply, "Supply_Name", "Supply_id", "请选择");
        }
        #endregion

        protected void pager_PageChanged(object sender, EventArgs e)
        {
            this.DataBindGrid();
        }
        private void DataBindGrid()
        {
            int count = 0;
            if (this.Hchange.Value == "1")
            {
                this.PageControl1.PageIndex = 1;
                this.Hchange.Value = "0";
            }
            StringBuilder SqlWhere = new StringBuilder();
            IList<SqlParam> IList_param = new List<SqlParam>();
            //if (!string.IsNullOrEmpty(this.txt_Search.Value))
            //{
            //    SqlWhere.Append(" and " + this.Searchwhere.Value + " like @obj ");
            //    IList_param.Add(new SqlParam("@obj", '%' + this.txt_Search.Value.Trim() + '%'));
            //}           

            DataTable dt = this._visa.GetResultVisaInfoPage(SqlWhere, IList_param, this.PageControl1.PageIndex, this.PageControl1.PageSize, ref count);
            ControlBindHelper.BindRepeaterList(dt, this.rp_Item);
            this.PageControl1.SetPageCount(count);
        }

        protected void lbtSearch_Click(object sender, EventArgs e)
        {
            this.DataBindGrid();
        }
        protected void Download_Click(object sender, EventArgs e)
        {
            
        }
    }
}